package com.example.demo1.controller;

import com.example.demo1.entity.book;
import com.example.demo1.repository.BookRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


import java.util.List;

@RestController
@RequestMapping("/")
public class BookHandler {
    @Autowired
    private BookRepository bookRepository;
    @CrossOrigin(origins = "*",maxAge = 3600)
    @GetMapping("/findAll")
    public List<book> findAll(){
        return bookRepository.findAll();
    }
}
